home *** CD-ROM | disk | FTP | other *** search
- property ioFieldList, iFieldFocus, ioFIeldFocus, iCurrentMotionStyleIndex, iCurrentVisualStyleIndex, ikMotionInstant, ikMotionWipe, ikMotionRoll, ikMotionRipple, iFirstTime, iSaveSeconds, iSaveFPS, iSaveDelayEnter, iSaveDelayHold, iSaveMark, iSaveAnimateTitle
-
- on birth me
- global goBulletsText, goSeconds, goFPS, goDelayEnter, goDelayHold
- set ioFieldList to [goBulletsText, goSeconds, goFPS, goDelayEnter, goDelayHold]
- set ikMotionInstant to 1
- set ikMotionWipe to 2
- set ikMotionRoll to 3
- set ikMotionRipple to 4
- set iCurrentMotionStyleIndex to ikMotionInstant
- set iCurrentVisualStyleIndex to 1
- set iFieldFocus to 1
- set iFirstTime to 1
- return me
- end
-
- on mInit me
- global goSeconds, goFPS, goDelayEnter, goDelayHold, goBullets, goMarkFrame, goAnimateTitle, goVisualStyles, goMotionStyles, goScoreMgr
- mInit(goMarkFrame, 4)
- mInit(goAnimateTitle, 22)
- if iFirstTime then
- mSetValue(goSeconds, 5)
- mSetValue(goFPS, 5)
- mSetValue(goDelayEnter, 5)
- mSetValue(goDelayHold, 5)
- mSetValue(goMarkFrame, 1)
- mSetValue(goAnimateTitle, 1)
- set iFirstTime to 0
- else
- mSetValue(goSeconds, iSaveSeconds)
- mSetValue(goFPS, iSaveFPS)
- mSetValue(goDelayEnter, iSaveDelayEnter)
- mSetValue(goDelayHold, iSaveDelayHold)
- mSetValue(goMarkFrame, iSaveMark)
- mSetValue(goAnimateTitle, iSaveAnimateTitle)
- end if
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- set goMotionStyles to 0
- set goMotionStyles to birth(script "RadioButton", 26, 4, 0, iCurrentMotionStyleIndex)
- if the machineType < 256 then
- mInit(goVisualStyles, the number of member "BulletsVisualStylesMac", iCurrentVisualStyleIndex, 8, 19)
- else
- mInit(goVisualStyles, the number of member "BulletsVisualStylesPC", iCurrentVisualStyleIndex, 8, 19)
- end if
- set the keyDownScript to "mCheckKey(goBullets)"
- end
-
- on mSetFieldFocus me, oWhom
- set where to getOne(ioFieldList, oWhom)
- if where = 0 then
- alert("Internal error - mSetFieldFocus could not find object")
- return
- end if
- set iFieldFocus to where
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- end
-
- on mCheckKey me
- if the key = TAB then
- set iFieldFocus to IncrMod(iFieldFocus, count(ioFieldList))
- set ioFIeldFocus to getAt(ioFieldList, iFieldFocus)
- pass()
- else
- if iFieldFocus = 1 then
- pass()
- else
- if (offset(the key, "0123456789") > 0) or (the key = BACKSPACE) then
- pass()
- else
- dontPassEvent()
- end if
- end if
- end if
- end
-
- on mSetNewMotionStyle me, theNewStyleIndex
- set iCurrentMotionStyleIndex to theNewStyleIndex
- end
-
- on mSetNewVisualStyle me, theNewStyleIndex
- set iCurrentVisualStyleIndex to theNewStyleIndex
- end
-
- on mValidate me
- set lastFieldOKFlag to mValidate(ioFIeldFocus)
- return lastFieldOKFlag
- end
-
- on mParseField me, theTextToParse, theHeaderFont, theHeaderSize, theBodyFont, theBodySize
- global gCastNumTextAsBitmap
- set castNumHeader to mModifyRichTextCM(goCastMgr, line 1 of theTextToParse, theHeaderFont, theHeaderSize)
- if castNumHeader = 0 then
- return 0
- end if
- set castNumHeaderTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumHeader)
- tell the stage
- pasteClipBoardInto(member castNumHeaderTarget)
- set the name of member castNumHeaderTarget to "RichText" && string(the ticks)
- end tell
- set castNumList to [castNumHeaderTarget]
- set maxWidth to 0
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumHeader
- set maxWidth to the width of member gCastNumTextAsBitmap
- set heightHeader to the height of member castNumHeader / the number of lines in the text of member castNumHeader
- repeat with thisLine = 2 to the number of lines in theTextToParse
- set thisBodyLine to line thisLine of theTextToParse
- set castNumBody to mModifyRichTextCM(goCastMgr, thisBodyLine, theBodyFont, theBodySize)
- if castNumBody = 0 then
- return 0
- end if
- set castNumBodyTarget to mFindFreeCastRun(goCastMgr, 1, 1)
- copyToClipBoard(member castNumBody)
- tell the stage
- pasteClipBoardInto(member castNumBodyTarget)
- set the name of member castNumBodyTarget to "RichText" && string(the ticks)
- end tell
- add(castNumList, castNumBodyTarget)
- set the picture of member gCastNumTextAsBitmap to the picture of member castNumBody
- set thisWidth to the width of member gCastNumTextAsBitmap
- if thisWidth > maxWidth then
- set maxWidth to thisWidth
- end if
- end repeat
- set heightBody to the height of member castNumBody / the number of lines in the text of member castNumBody
- set maxHeight to max(heightHeader, heightBody)
- add(castNumList, maxHeight)
- add(castNumList, maxWidth)
- return castNumList
- end
-
- on mCreate me
- global goMarkFrame, goMotionStyles, goVisualStyles, goScoreMgr, goCastMgr, gDevelopmentFlag, gCastNumTextAsBitmap, goAnimateTitle, goPlatform
- if not mValidate(me) then
- return
- end if
- if the last char in field "BulletsText" = RETURN then
- delete char -30000 of field "BulletsText"
- end if
- if field "BulletsText" = EMPTY then
- alert("Please enter some text for the Bullet.")
- return
- end if
- if the number of lines in field "BulletsText" < 2 then
- alert("Bullets requires at least two lines of text, one header and any number of bullets.")
- return
- end if
- tell the stage
- set theStageFrame to the frame
- end tell
- set castNumVisualStyle to mGetCastNum(goVisualStyles, iCurrentVisualStyleIndex)
- set theVisualStyleName to the name of cast castNumVisualStyle
- set theHeaderFont to word 2 of theVisualStyleName
- set theHeaderSize to word 3 of theVisualStyleName
- set theBodyFont to word 4 of theVisualStyleName
- set theBodySize to word 5 of theVisualStyleName
- set theSeconds to integer(field "Seconds")
- set animateTitleFlag to mGetValue(goAnimateTitle)
- set fps to integer(field "FPS")
- set nFrames to integer(theSeconds * fps)
- set delayEnter to integer(field "DelayEnter")
- set delayHold to integer(field "DelayHold")
- set markFirst to mGetValue(goMarkFrame)
- set theForeColor to 255
- set theBackColor to 0
- if the machineType < 256 then
- set charsToPrepend to "ΓÇó "
- else
- set charsToPrepend to "- "
- end if
- set nSourceLines to the number of lines in field "BulletsText"
- set theSourceText to field "BulletsText"
- repeat with thisLine = 2 to nSourceLines
- put charsToPrepend before line thisLine of theSourceText
- end repeat
- set bulletsList to mParseField(me, theSourceText, theHeaderFont, theHeaderSize, theBodyFont, theBodySize)
- if bulletsList = 0 then
- return
- end if
- set widthIndex to count(bulletsList)
- set maxWidth to getAt(bulletsList, widthIndex)
- deleteAt(bulletsList, widthIndex)
- set heightIndex to count(bulletsList)
- set maxHeight to getAt(bulletsList, heightIndex)
- deleteAt(bulletsList, heightIndex)
- set theStageWidth to mGetStageWidth(goScoreMgr)
- set leftEdge to integer((theStageWidth / 2) - (maxWidth / 2))
- set theStageHeight to mGetStageHeight(goScoreMgr)
- set nextV to integer((theStageHeight / 2) - (nSourceLines * value(maxHeight) / 2))
- set locVList to []
- repeat with thisLine = 1 to nSourceLines
- add(locVList, nextV)
- set nextV to nextV + value(maxHeight)
- end repeat
- case iCurrentMotionStyleIndex of
- ikMotionInstant:
- set thisTransition to "Dissolve, Pixels Fast"
- if animateTitleFlag then
- set nFrames to 1
- else
- set nFrames to 2
- end if
- ikMotionWipe:
- set thisTransition to "Wipe Down"
- if animateTitleFlag then
- set nFrames to 1
- else
- set nFrames to 2
- end if
- ikMotionRoll:
- set thisTransition to 0
- set nFramesPerTransition to (theSeconds * fps) + 1
- if animateTitleFlag then
- set nFrames to nFramesPerTransition * nSourceLines
- else
- set nFrames to (nFramesPerTransition * (nSourceLines - 1)) + 1
- end if
- ikMotionRipple:
- set thisTransition to 0
- set nAnimationFrames to theSeconds * fps
- if animateTitleFlag then
- set nFrames to nAnimationFrames + 1
- else
- set nFrames to nAnimationFrames + 2
- end if
- end case
- if not mInit(goScoreMgr, nFrames, nSourceLines) then
- return
- end if
- set chList to []
- repeat with i = 1 to nSourceLines
- set chNext to mGetNextSelectedChannel(goScoreMgr)
- add(chList, chNext)
- end repeat
- set theFrameNum to mGetStartFrame(goScoreMgr)
- set frameList to []
- repeat with i = theFrameNum to theFrameNum + nFrames - 1
- add(frameList, [i])
- end repeat
- if markFirst then
- set theLabel to "AW.Bullet." & word 1 of the text of field "BulletsText" & " " & mGetGeneratedScoreSelection(goScoreMgr)
- set firstFrame to getAt(frameList, 1)
- add(firstFrame, [#label, theLabel])
- setAt(frameList, 1, firstFrame)
- end if
- set relFrameCount to 1
- if not animateTitleFlag then
- if thisTransition <> 0 then
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#transition, thisTransition])
- setAt(frameList, relFrameCount, currentFrame)
- end if
- set chHeader to getAt(chList, 1)
- set castNumHeader to getAt(bulletsList, 1)
- set locVHeader to getAt(locVList, 1)
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, -delayEnter])
- add(currentFrame, [#sprite, chHeader, castNumHeader, theForeColor, theBackColor, leftEdge, locVHeader, 0, 0])
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- end if
- if (iCurrentMotionStyleIndex = ikMotionInstant) or (iCurrentMotionStyleIndex = ikMotionWipe) then
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#transition, thisTransition])
- repeat with thisItem = 1 to nSourceLines
- set chItem to getAt(chList, thisItem)
- set castNumItem to getAt(bulletsList, thisItem)
- set locVItem to getAt(locVList, thisItem)
- add(currentFrame, [#tempo, -delayHold])
- add(currentFrame, [#sprite, chItem, castNumItem, theForeColor, theBackColor, leftEdge, locVItem, 0, 0])
- setAt(frameList, relFrameCount, currentFrame)
- end repeat
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- else
- set theStageRight to mGetStageRight(goScoreMgr)
- set offStagePos to theStageRight + 10
- if animateTitleFlag then
- set startItem to 1
- set locHList to []
- else
- set startItem to 2
- set locHList to [leftEdge]
- end if
- if iCurrentMotionStyleIndex = ikMotionRoll then
- repeat with i = startItem to nSourceLines
- add(locHList, offStagePos)
- end repeat
- set nFramesPerAnimation to theSeconds * fps
- set hInc to float(leftEdge - offStagePos) / float(nFramesPerAnimation)
- repeat with thisBullet = startItem to nSourceLines
- set thisH to getAt(locHList, thisBullet)
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, fps])
- setAt(frameList, relFrameCount, currentFrame)
- repeat with i = 1 to nFramesPerAnimation
- set thisH to integer(thisH + hInc)
- if thisH < leftEdge then
- set thisH to leftEdge
- end if
- setAt(locHList, thisBullet, thisH)
- set currentFrame to getAt(frameList, relFrameCount)
- repeat with thisItem = 1 to nSourceLines
- set chItem to getAt(chList, thisItem)
- set castNumItem to getAt(bulletsList, thisItem)
- set locVItem to getAt(locVList, thisItem)
- set locHItem to getAt(locHList, thisItem)
- add(currentFrame, [#sprite, chItem, castNumItem, theForeColor, theBackColor, locHItem, locVItem, 0, 0])
- end repeat
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- end repeat
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, -delayHold])
- repeat with thisItem = 1 to nSourceLines
- set chItem to getAt(chList, thisItem)
- set castNumItem to getAt(bulletsList, thisItem)
- set locVItem to getAt(locVList, thisItem)
- set locHItem to getAt(locHList, thisItem)
- add(currentFrame, [#sprite, chItem, castNumItem, theForeColor, theBackColor, locHItem, locVItem, 0, 0])
- end repeat
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- end repeat
- else
- set nBulletsToMove to nSourceLines - startItem + 1
- set pctOverlap to 0.25
- set hDistance1Line to float(leftEdge - offStagePos)
- set effectiveNLines to 1.0 + (pctOverlap * nBulletsToMove)
- set totalHDistance to effectiveNLines * hDistance1Line
- set hInc to totalHDistance / float(nAnimationFrames)
- set staggerOffset to -1 * integer(hDistance1Line * pctOverlap)
- set multiplier to 0
- repeat with thisItem = startItem to nSourceLines
- set startingPos to offStagePos + (multiplier * staggerOffset)
- add(locHList, startingPos)
- set multiplier to multiplier + 1
- end repeat
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, fps])
- setAt(frameList, relFrameCount, currentFrame)
- repeat with animFrame = 1 to nAnimationFrames
- set currentFrame to getAt(frameList, relFrameCount)
- repeat with thisBullet = 1 to nSourceLines
- set chItem to getAt(chList, thisBullet)
- set castNumItem to getAt(bulletsList, thisBullet)
- set locVItem to getAt(locVList, thisBullet)
- set locHItem to getAt(locHList, thisBullet)
- add(currentFrame, [#sprite, chItem, castNumItem, theForeColor, theBackColor, locHItem, locVItem, 0, 0])
- if locHItem > leftEdge then
- set thisH to integer(locHItem + hInc)
- if thisH < leftEdge then
- set thisH to leftEdge
- end if
- setAt(locHList, thisBullet, thisH)
- end if
- end repeat
- setAt(frameList, relFrameCount, currentFrame)
- set relFrameCount to relFrameCount + 1
- set theFrameNum to theFrameNum + 1
- end repeat
- set currentFrame to getAt(frameList, relFrameCount)
- add(currentFrame, [#tempo, -delayHold])
- repeat with thisItem = 1 to nSourceLines
- set chItem to getAt(chList, thisItem)
- set castNumItem to getAt(bulletsList, thisItem)
- set locVItem to getAt(locVList, thisItem)
- add(currentFrame, [#sprite, chItem, castNumItem, theForeColor, theBackColor, leftEdge, locVItem, 0, 0])
- end repeat
- setAt(frameList, relFrameCount, currentFrame)
- set theFrameNum to theFrameNum + 1
- set relFrameCount to relFrameCount + 1
- end if
- end if
- mWriteFrame(goScoreMgr, frameList)
- set labelName to "Bullets" & goPlatform
- go(label(labelName) + 2)
- if not gDevelopmentFlag then
- tell the stage
- go(theStageFrame)
- end tell
- end if
- mClean(goScoreMgr)
- end
-
- on mCleanUp me
- global goMotionStyles, goAnimateTitle, goSeconds, goFPS, goDelayEnter, goDelayHold, goMarkFrame
- mCleanUp(goMotionStyles)
- set iSaveSeconds to mGetValue(goSeconds)
- set iSaveFPS to mGetValue(goFPS)
- set iSaveDelayEnter to mGetValue(goDelayEnter)
- set iSaveDelayHold to mGetValue(goDelayHold)
- set iSaveMark to mGetValue(goMarkFrame)
- set iSaveAnimateTitle to mGetValue(goAnimateTitle)
- mCleanUp(goMarkFrame)
- mCleanUp(goAnimateTitle)
- end
-